package com.exchange.dto;

import com.exchange.entity.Order;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class OrderDto {
    private Long id;
    private String orderNumber;
    private Long exchangeCodeId;
    private Long merchantId;
    private String customerName;
    private String customerPhone;
    private String customerEmail;
    private Order.DeliveryType deliveryType;
    private String shippingAddress;
    private Order.OrderStatus orderStatus;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private LocalDateTime shippedAt;
    private LocalDateTime deliveredAt;
    private LocalDateTime cancelledAt;
    
    public static OrderDto fromEntity(Order order) {
        OrderDto dto = new OrderDto();
        dto.setId(order.getId());
        dto.setOrderNumber(order.getOrderNumber());
        dto.setExchangeCodeId(order.getExchangeCodeId());
        dto.setMerchantId(order.getMerchantId());
        dto.setCustomerName(order.getCustomerName());
        dto.setCustomerPhone(order.getCustomerPhone());
        dto.setCustomerEmail(order.getCustomerEmail());
        dto.setDeliveryType(order.getDeliveryType());
        dto.setShippingAddress(order.getShippingAddress());
        dto.setOrderStatus(order.getOrderStatus());
        dto.setCreatedAt(order.getCreatedAt());
        dto.setUpdatedAt(order.getUpdatedAt());
        dto.setShippedAt(order.getShippedAt());
        dto.setDeliveredAt(order.getDeliveredAt());
        dto.setCancelledAt(order.getCancelledAt());
        return dto;
    }
}